package com.itheima.d1_polymorphism;

/*
    目标：掌握使用多态的好处，以及多态下的类型转换问题。
 */
public class Test2 {
    public static void main(String[] args) {
        People p1 = new Teacher();
        Student s = new Student();
        testRun(s);
        Teacher t = new Teacher();
        testRun(t);

    }

    public static void testRun(People s) {
        System.out.println("开始");
        s.run();
        if (s instanceof Student) {
            Student ss = (Student) s;
            ss.str();
        }
        if (s instanceof Teacher) {
            Teacher tt = (Teacher) s;
            tt.set();
        }
        System.out.println("结束");
    }
}
